<?php
$this->load->view('header');

if (strlen($this->session->flashdata('Error')) > 0) {
    echo '<div class="alert alert-danger alert-dismissable">';
    echo '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>' . $this->session->flashdata('Error') . '</div>';
    $this->session->unset_userdata('Error');
} elseif (strlen($this->session->flashdata('Success')) > 0) {
    echo '<div class="alert alert-success alert-dismissable">';
    echo '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>' . $this->session->flashdata('Success') . '</div>';
    $this->session->unset_userdata('Success');
}
?>
<script type="text/javascript">
function add_data(type) {
	$.post("<?= site_url() ?>setup/add_facility_view", {
		type: type 		
	}, 
	function(data) {
		$('#loader').html(data);
	});
}
function edit_data(name,type,desc){
	$.post("<?= site_url() ?>setup/edit_facility_view", {
		name: name, type: type, desc: desc 		
	}, 
	function(data) {
		$('#loader').html(data);
	});
}
function delete_data(name, type){		
	if (confirm("Apakah Anda Yakin Ingin Delete Facility '"+ name +"' ?")){
		$.post("<?= site_url() ?>setup/delete_facility", {name: name, type: type}, function(data) {
			window.location = '<?php echo base_url();?>setup/work_facility';
		});
	}
}
</script>

<div id="loader" class="container">
	<div class="col-md-offset-1">
		<div class="col-md-11">			
			<div class="panel-heading">
				<h4 class="panel-title"><b class="caret"></b><b> Master Facility</b></h4>
			</div>
			<div class="panel-body well">													
				<div class="col-md-6">								
					<form method="post" name="fasilitas_kerja" action="#" onsubmit="return cekDulu(this);">
						<div class="table-responsive">
						<table class="table table-bordered table-condensed table-striped">
							<thead>
							<tr class="head">
								<th class="tblhead" style="width:10%;text-align:center;">No</th>
								<th class="tblhead" style="width:55%;text-align:center;">Work Facility</th>
								<th class="tblhead" style="width:35%;text-align:center;">Action</th>
							</tr>
							</thead>
							<tbody>
								<?php
								if (empty($list_fasilitas_kerja)) {
									?>
									<tr><td colspan="3" style="text-align:center">No Data Available</td></tr>
									<?php
								} else {
									$no_urut = 1;
									foreach ($list_fasilitas_kerja as $row) {
								?>
								<tr>
									<?php
										$ri_name1 = $row["RI_NAME"];
										$ri_type1 = $row["RI_TYPE"];
										$ri_desc1 = $row["RI_DESC"];
									?>
									<td bgcolor="#FFFFFF" class="tbl-content-c" style="text-align:center;"><?php echo $no_urut; ?>.</td>
									<td bgcolor="#FFFFFF" class="tbl-content-c" style="text-align:left;"><?php echo $ri_name1; ?></td>
									<td bgcolor="#FFFFFF" class="tbl-content-c" style="text-align:center;">
										<a class="btn btn-sm btn-warning" href="#" onclick="edit_data('<?php echo $ri_name1; ?>','<?php echo $ri_type1; ?>','<?php echo $ri_desc1; ?>');">
											<!--span class="glyphicon glyphicon-edit"></span--> Edit</a>
										<a class="btn btn-sm btn-danger" href="#" onclick="delete_data('<?php echo $ri_name1; ?>','<?php echo $ri_type1; ?>');">
											<!--span class="glyphicon glyphicon-remove"></span--> Delete</a>
									</td>															
								</tr>
								<?php $no_urut++;															 
									}
								}
								?>														
							</tbody>													
						</table>												
						</div>
						<div class="col-md-4">
							<button type="button" class="btn btn-success btn-block" onclick="add_data('<?php echo $ri_type1 ?>');">
							<!--span class="glyphicon glyphicon-plus"></span--> Add New</button>
						</div>											
					</form>
					<div style="padding:20px;"></div>
				</div>

<!-- ----------------------------[ FASILITAS RUANG KERJA ]---------------------------- -->
				<div class="col-md-6">
					<form method="post" name="fasilitas_ruaker" action="#" onsubmit="return cekDulu(this);">
						<div class="table-responsive">
						<table class="table table-bordered table-condensed table-striped">
							<thead>
							<tr class="head">
								<th class="tblhead" style="width:10%;text-align:center;">No</th>
								<th class="tblhead" style="width:55%;text-align:center;">Room Facility</th>
								<th class="tblhead" style="width:35%;text-align:center;">Action</th>
							</tr>
							</thead>
							<tbody>
								<?php
								if (empty($list_fasilitas_ruang_kerja)) {
									?>
									<tr><td colspan="3" style="text-align:center">No Data Available</td></tr>
									<?php
								} else {
									$no_urut = 1;
									foreach ($list_fasilitas_ruang_kerja as $row) {
								?>
								<tr>
									<?php
										$ri_name2 = $row["RI_NAME"];
										$ri_type2 = $row["RI_TYPE"];
										$ri_desc2 = $row["RI_DESC"];
									?>
									<td bgcolor="#FFFFFF" class="tbl-content-c" style="text-align:center;"><?php echo $no_urut; ?>.</td>
									<td bgcolor="#FFFFFF" class="tbl-content-c" style="text-align:left;"><?php echo $ri_name2; ?></td>
									<td bgcolor="#FFFFFF" class="tbl-content-c" style="text-align:center;">
										<a class="btn btn-sm btn-warning" href="#" onclick="edit_data('<?php echo $ri_name2; ?>','<?php echo $ri_type2; ?>','<?php echo $ri_desc2; ?>');">
										<!--span class="glyphicon glyphicon-edit"></span--> Edit</a>
										<a class="btn btn-sm btn-danger" href="#" onclick="delete_data('<?php echo $ri_name2; ?>','<?php echo $ri_type2; ?>');">
										<!--span class="glyphicon glyphicon-remove"></span--> Delete</a>
									</td>
								</tr>
								<?php $no_urut++;															 
									}
								}
								?>		
							</tbody>													
						</table>												
						</div>
						<div class="col-md-4">
							<button type="button" class="btn btn-success btn-block" onclick="add_data('<?php echo $ri_type2 ?>');">
							<!--span class="glyphicon glyphicon-plus"></span--> Add New</button>
						</div>
					</form>
				</div>											
			</div>
		</div>
	</div>
</div>

<?php $this->load->view('footer'); ?>